package com.tsunami.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tsunami.authority.entity.common.OptLog;
import com.tsunami.authority.enums.common.LogType;
import com.tsunami.demo.mapper.OptLogMapper;
import com.tsunami.demo.service.IOptLogService;
import com.tsunami.log.entity.OptLogDTO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户操作日志 服务实现类
 * </p>
 *
 * @author lx
 * @since 2021-09-23
 */
@Service
public class OptLogServiceImpl extends ServiceImpl<OptLogMapper, OptLog> implements IOptLogService {

    @Override
    public Boolean save(OptLogDTO entity) {
        OptLog log = new OptLog();
        log.setRequestIp(entity.getRequestIp());
        log.setType(LogType.get(entity.getType()));
        log.setDescription(entity.getDescription());
        log.setCreateUser(entity.getCreateUser());
        log.setUserName(entity.getUserName());
        log.setClassPath(entity.getClassPath());
        log.setActionMethod(entity.getActionMethod());
        log.setRequestUri(entity.getRequestUri());
        log.setHttpMethod(entity.getHttpMethod());
        log.setParams(entity.getParams());
        log.setResult(entity.getResult());
        log.setExDesc(entity.getExDesc());
        log.setExDetail(entity.getExDetail());
        log.setStartTime(entity.getStartTime());
        log.setFinishTime(entity.getFinishTime());
        log.setConsumingTime(entity.getConsumingTime());
        log.setUa(entity.getUa());
        return super.save(log);
    }
}
